<?php

namespace Tests\XinSheng;

use fize\math\Financial;
use PHPUnit\Framework\TestCase;
use XinSheng\ModelByOutsideRate;

class TestModelByOutsideRate extends TestCase
{

    public function testSetFront()
    {

    }

    public function testGetOutsideRate()
    {

    }

    public function testGetPlan()
    {
        $mbor = new ModelByOutsideRate(
            1000000.00, 0.8, 200000.00, 0.8, 0.00,
            0.8, 0.00, 0.8, 20000.00, 0.45,
            0.08, 36
        );
        $mbor->setFront(0.11);
        $plan = $mbor->getPlan();
        var_dump($plan);
        self::assertIsArray($plan);

        $cashflow = [];
        foreach ($plan as $item) {
            $cashflow[] = $item['cash_flow'];
        }
        $irr2 = Financial::irr($cashflow);
        $rate = $irr2 * 12;
        var_dump($rate);
    }
}
